package com.loie.datacenter;

import com.loie.datacenter.config.DgMVCProperties;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.http.HttpStatus;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zhl
 */
//@ComponentScans({
//        @ComponentScan(value = {"com.loie.datacenter"})
//})
@EnableSwagger2
@Slf4j
@SpringBootApplication()
@EnableConfigurationProperties({DgMVCProperties.class})
@MapperScan("${mybatis-plus.mapper-scan:com.loie.**.mapper}")
@EnableCaching
public class DataCenterApplication {
    public static void main(String[] args) {
        SpringApplication.run(DataCenterApplication.class, args);
    }


    @Bean
    public
    WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
        return (factory -> {
            ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/pages/index.html");
            factory.addErrorPages(errorPage404);
        });

    }

}
